import { Tooltip } from 'antd';
import pageStyles from '@/common/pageLayout.less';
import { formatDecimalFour } from '../../Acommon';
import { ColumnsRenderFun, DictionaryRenderFun } from '@/common';

/**
 * 表格信息 展示和操作
 * @returns
 */
const getTableColumns = (
  /** 资源权限参数 */
  curRes: Record<string, any>,
) => {
  return [
    {
      title: '物资编号',
      dataIndex: 'materialCode',
      key: 'materialCode',
      width: 150,
      fixed: 'left',
      ellipsis: {
        showTitle: true,
      },
      visible: true,
      unDrag: true,
      sorter: (a: any, b: any) => (a.materialCode > b.materialCode ? 1 : -1),
      render: (text: string, record: Record<string, any>) => ColumnsRenderFun({ text, isTooltip: true }),
    },
    {
      title: '物资名称',
      dataIndex: 'assetName',
      key: 'assetName',
      width: 150,
      fixed: 'left',
      ellipsis: {
        showTitle: true,
      },
      visible: true,
      unDrag: true,
      sorter: (a: any, b: any) => (a.assetName > b.assetName ? 1 : -1),
      render: (text: string, record: Record<string, any>) => ColumnsRenderFun({ text, isTooltip: true }),
    },
    {
      title: '物资种类',
      dataIndex: 'type',
      key: 'type',
      width: 130,
      visible: true,
      sorter: (a: any, b: any) => (a.type > b.type ? 1 : -1),
      render: (text: string | number) => {
        return (
          <Tooltip title={text == '0' ? '材料' : text == '1' ? '资产' : '--'}>
            <div className={pageStyles['over-flow-hidden']}>{text == '0' ? '材料' : text == '1' ? '资产' : '--'}</div>
          </Tooltip>
        );
      },
    },
    {
      title: '物资分类',
      dataIndex: 'assetClassName',
      key: 'assetClassName',
      width: 130,
      ellipsis: {
        showTitle: true,
      },
      visible: true,
      unDrag: true,
      sorter: (a: any, b: any) => (a.assetClassName > b.assetClassName ? 1 : -1),
      render: (text: string) => DictionaryRenderFun({ text, isState: false }),
    },
    {
      title: '物资状态',
      dataIndex: 'assetStateName',
      key: 'assetStateName',
      width: 130,
      visible: true,
      sorter: (a: any, b: any) => (a.assetStateName > b.assetStateName ? 1 : -1),
      render: (text: number | null) => DictionaryRenderFun({ text, isState: false }),
    },
    // {
    //   title: '所属仓库',
    //   dataIndex: 'assetStoreName',
    //   key: 'assetStoreName',
    //   width: 130,
    //   sorter: (a: any, b: any) => tableSorter(a, b, 'assetStoreName'),
    //   render: (text: string) => renderTableText(text, true),
    // },
    {
      title: '供应商',
      dataIndex: 'supplier',
      key: 'supplier',
      width: 130,
      visible: true,
      sorter: (a: any, b: any) => (a?.assetjson?.supplier > b?.assetjson?.supplier ? 1 : -1),
      render: (text: number | null, record: Record<string, any>) => ColumnsRenderFun({ text: record?.assetjson?.supplier, isTooltip: true }),
    },
    {
      title: '品牌',
      dataIndex: 'brandType',
      key: 'brandType',
      width: 130,
      visible: true,
      sorter: (a: any, b: any) => (a.brandType > b.brandType ? 1 : -1),
      render: (text: number | null) => ColumnsRenderFun({ text, isTooltip: true }),
    },
    {
      title: '规格型号',
      dataIndex: 'paramsInfo',
      key: 'paramsInfo',
      width: 130,
      visible: true,
      sorter: (a: any, b: any) => (a.paramsInfo > b.paramsInfo ? 1 : -1),
      render: (text: string) => ColumnsRenderFun({ text, isTooltip: true }),
    },
    {
      title: '产权',
      dataIndex: 'ownershipName',
      key: 'ownershipName',
      width: 130,
      visible: true,
      sorter: (a: any, b: any) => (a.ownershipName > b.ownershipName ? 1 : -1),
      render: (text: string) => DictionaryRenderFun({ text }),
    },
    {
      title: '数量',
      dataIndex: 'quantityOrArea',
      key: 'quantityOrArea',
      width: 100,
      visible: true,
      sorter: (a: any, b: any) => (a.quantityOrArea > b.quantityOrArea ? 1 : -1),
      // render: (text: number | null) => formatDecimal(text),
      render: (text: string) => ColumnsRenderFun({ text, isTooltip: true }),
    },
    {
      title: '剩余数量',
      dataIndex: 'residueNum',
      key: 'residueNum',
      width: 140,
      visible: true,
      sorter: (a: any, b: any) => (a.residueNum > b.residueNum ? 1 : -1),
      // render: (text: number | null) => formatDecimal(text),
      render: (text: string) => ColumnsRenderFun({ text, isTooltip: true }),
    },
    {
      title: '计量单位',
      dataIndex: 'unitOfMeasurementName',
      key: 'unitOfMeasurementName',
      width: 140,
      visible: true,
      sorter: (a: any, b: any) => (a.unitOfMeasurementName > b.unitOfMeasurementName ? 1 : -1),
      render: (text: number | null) => DictionaryRenderFun({ text, isState: false }),
    },
    {
      title: '单价（元）',
      dataIndex: 'assetValue',
      key: 'assetValue',
      width: 140,
      visible: true,
      sorter: (a: any, b: any) => (a.assetValue > b.assetValue ? 1 : -1),
      render: (text: number | null) => formatDecimalFour(text),
    },
    {
      title: '总价（元）',
      dataIndex: 'totalValue',
      key: 'totalValue',
      width: 140,
      visible: true,
      sorter: (a: any, b: any) => (a.totalValue > b.totalValue ? 1 : -1),
      render: (text: number | null) => formatDecimalFour(text),
    },
    {
      title: '管理员单位',
      dataIndex: 'assetCompanyName',
      key: 'assetCompanyName',
      visible: true,
      width: 140,
      sorter: (a: any, b: any) => (a?.assetCompanyName > b?.assetCompanyName ? 1 : -1),
      render: (text: string | null) => ColumnsRenderFun({ text }),
    },
    {
      title: '管理员部门',
      dataIndex: 'assetDepartmentName',
      key: 'assetDepartmentName',
      visible: true,
      width: 140,
      sorter: (a: any, b: any) => (a?.assetDepartmentName > b?.assetDepartmentName ? 1 : -1),
      render: (text: string | null) => ColumnsRenderFun({ text }),
    },
    {
      title: '管理员岗位',
      dataIndex: 'assetPositionName',
      key: 'assetPositionName',
      visible: true,
      width: 140,
      sorter: (a: any, b: any) => (a?.assetPositionName > b?.assetPositionName ? 1 : -1),
      render: (text: string | null) => ColumnsRenderFun({ text }),
    },
    {
      title: '管理员',
      dataIndex: 'asseterName',
      key: 'asseterName',
      visible: true,
      width: 140,
      sorter: (a: any, b: any) => (a?.asseterName > b?.asseterName ? 1 : -1),
      render: (text: string | null) => ColumnsRenderFun({ text }),
    },
  ];
};

export { getTableColumns };
